package com.lc.activiti.sys.controller;


import com.lc.activiti.config.Result;
import com.lc.activiti.sys.entity.SysLeave;
import com.lc.activiti.sys.service.SysLeaveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * 请假表(SysLeave)表控制层
 *
 * @author 骆超
 * @since 2021-06-21 17:40:53
 */
@RestController
@RequestMapping("sysLeave")
@Api(tags = "请假")
public class SysLeaveController {
    /**
     * 服务对象
     */
    @Resource
    private SysLeaveService sysLeaveService;

    /**
     * 保存或提交请假信息
     * @author 骆超
     * @date 2021/6/22
     * @param sysLeave 请假信息实例
     * @return com.lc.activiti.config.Result
     */
    @PostMapping("saveLeaveInfo")
    @ApiOperation("保存或提交请假信息")
    public Result saveLeaveInfo(@RequestBody SysLeave sysLeave) throws IOException {
        return sysLeaveService.saveLeaveInfo(sysLeave);
    }

    /**
     * 获取请假信息
     * @author 骆超
     * @date 2021/6/22
     * @param sysLeave SysLeave类实例
     * @return com.lc.activiti.config.Result
     */
    @PostMapping("getLeaveData")
    @ApiOperation("获取请假信息")
    public Result getLeaveData(@RequestBody SysLeave sysLeave){
        return Result.success(sysLeaveService.getById(sysLeave));
    }

    /**
     * 获取个人请假
     * @author 骆超
     * @date 2021/6/23
     * @param sysLeave SysLeave类实例
     * @return com.lc.activiti.config.Result
     */
    @PostMapping("getLeavePage")
    @ApiOperation("获取个人请假")
    public Result getLeavePage(@RequestBody SysLeave sysLeave){
        return sysLeaveService.getLeavePage(sysLeave);
    }

    /**
     * 删除请假
     * @author 骆超
     * @date 2021/6/24
     * @param sysLeave SysLeave类实例
     * @return com.lc.activiti.config.Result
     */
    @PostMapping("deleteLeave")
    @ApiOperation("删除请假")
    public Result deleteLeave(@RequestBody SysLeave sysLeave){
        return Result.success(sysLeaveService.removeById(sysLeave));
    }

}
